Learn SpriteBuilder for iOS Game Development by Steffen Itterheim

Learn SpriteBuilder for iOS Game Development by Steffen Itterheim

Author:Steffen Itterheim [Itterheim , Steffen]
Language: eng
Format: epub, mobi, azw3, pdf
ISBN: 9781484202630
Publisher: Apress
Published: 2014-11-21T08:00:00+00:00


Listing 7-10. Declaring the GameState methods and properties

#import <Foundation/Foundation.h>

@interface GameState : NSObject

+(GameState*) sharedGameState;

@property CGFloat musicVolume;

@property CGFloat effectsVolume;

@end

The sharedGameState class is prefixed with a +, which makes it a class method accessible from any other class. It will return, and if necessary create, the single instance of the GameState class. The properties will enable you to change and retrieve the volumes as if they were properties of the class, when in fact they will run custom setter and getter methods instead of referring to ivars.

Add the code in Listing 7-11 just below the @implementation GameState line in the GameState.m file. This creates a single instance of the class if there is no instance yet. It will then return the instance.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.